<script type="text/javascript">
$(document).ready(function(){
  $('.actor-list-row').click(function(){
    var actor_id = $(this).attr('id');
    //$('#facade').css('height',$(document).height());
    $('#facade').css('display','block');
    if(actor_id == 'nomatch'){
        $.ajax({
            type: "GET",
            url: '/matter/add-actor',
            success: function(data){
            	$('#actor-details-popup').empty();
    	        $('#actor-details-popup').html(data);
    	        $('#actor-details-popup').css('display', 'block');
    	        $('#facade').css('display','none');
    	        $('#name').focus();
            }
        });
    } else {
	    $.ajax({
	      url: '/matter/actor/',
	      type: 'POST',
	      data: { actor_id:actor_id },
	      success: function(data){
	        $('#actor-details-popup').empty();
	        $('#actor-details-popup').html(data);
	        $('#actor-details-popup').css('display', 'block');
	        $('#facade').css('display','none');
	      }
	    });
    }
  });

  $('.delete-from-list').click(function(){
    var del_conf = confirm("Deleting Actor from table. Are you sure?");
	if(del_conf == 1){
    var aid = $(this).attr('id');
    $.ajax({
      url : '/matter/delete-actor',
      type: 'POST',
      data: { aid:aid },
      success: function(data){
         if(isNaN(parseInt(data)))
             alert(data);
         else
        	 location.reload();
      }    
      });
	}
    return false;
  });
});
</script>

<ul class="phpip-list" id="actors-list">
<?php foreach($this->actors as $actor): ?>
    <li class="actor-list-row" id="<?=$actor['id']?>">
    	<div class="col-name"><?=htmlentities($actor['name'])?></div>
    	<div class="col-firstname"><?=htmlentities(@$actor['first_name'])?></div>
    	<div class="col-display"><?=htmlentities(@$actor['display_name'])?></div>
    	<div class="col-company"><?=htmlentities(@$actor['company_name'])?></div>
    	<div class="col-delete" ><span class="delete-from-list ui-icon ui-icon-trash" id="<?=$actor['id']?>" style="float:right;" title="Delete actor"/></div>
    </li>
<?php endforeach; ?>
</ul>
